package fr.umlv.m2.recipes.ideas.bean;

import java.io.Serializable;
/**
 * Define an ingredient uses to handle all the ingredients of a recipe
 * @author Christophe Chillan
 *
 */
@SuppressWarnings("serial")
public class IngredientBean implements Serializable {
	
	private int id;
	private String name;
	private String energy;
	private float price;
	/**
	 * Creation of an ingredient bean
	 */
	public IngredientBean(){}
	
	/**
	 * Creation of an ingredient bean
	 * @param name
	 * @param price
	 */
	public IngredientBean(String name,float price){
		this.name = name;
		this.price = price;
		energy = new String();
		id=-1;
	}
	
	/**
	 * Creation of an ingredient bean
	 * @param name
	 * @param price
	 * @param energy
	 */
	public IngredientBean(String name, float price, String energy){
		this(name, price);
		this.energy = energy;
	}
	
	/**
	 * Creation of an ingredient bean
	 * @param name
	 * @param id
	 */
	public IngredientBean(String name, int id){
		this.name = name;
		this.id = id;
	}
	
	/**
	 * Give the id of an {@link IngredientBean}
	 * @return the id stored in the database of the ingredient
	 */
	public int getId() {
		return id;
	}
	/**
	 * Set the id of the IngredientBean
	 * @param id
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * Give the name of the {@link IngredientBean}
	 * @return the name of the ingredient in the database
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Set the name of the IngredientBean
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Get the energy part of the IngredientBean
	 * @return the energu of the IngredientBean
	 */
	public String getEnergy() {
		return energy;
	}
	
	/**
	 * Set the energy of the IngredientBean
	 * @param energy
	 */
	public void setEnergy(String energy) {
		this.energy = energy;
	}
	
	/**
	 * Get the price of the IngredientBean
	 * @return the price of the IngredientBean in the database
	 */
	public float getPrice() {
		return price;
	}
	
	/**
	 * Set the price of the IngredientBean
	 * @param price
	 */
	public void setPrice(float price) {
		this.price = price;
	}
	
	/**
	 * @see Object
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("INGREDIENT : ").append(name).append("\n");
		builder.append("prix : ").append(price).append("\n");
		if(energy.length()>0){
			builder.append("apport energetique : ").append(energy);
		}
		return builder.toString();
	}

}
